using UnityEngine;
using System.Collections;

public class SpearScript : MonoBehaviour {

    private GameObject[] obs;
    private Vector3 moveDirection;
    public float damage = 25.0f;
    private int life = 0;
    public int maxLife = 50;
    
    // Use this for initialization
    void Start()
    {

    }
    
    // Update is called once per frame
    void Update()
    {
        if(Network.isServer){
            life++;
            print (life);
            if (life >= maxLife)
                GameObject.Destroy(gameObject);
        }
    }
    
    void OnTriggerEnter(Collider other){
        EnemyHealth e = other.transform.GetComponent<EnemyHealth>();
        if(e != null)
            e.damage(damage);
            
        PlayerHealth p = other.transform.GetComponent<PlayerHealth>();
        if(p != null)
            p.damage(damage);
    }
}